jq(document).ready(function(){
	
	//全局提示
	jq("#dialog-Member").dialog({
		resizable: false,
		height:120,
		modal: true,
		autoOpen: false
	});
	
	//AUTO COMPLETE
	var cache = {},
		lastXhr;
	jq( "#tags" ).autocomplete({
		minLength: 1,
		source: function( request, response ) {
			var term = request.term;
			if ( term in cache ) {
				response( cache[ term ] );
				return;
			}
			var query = encodeURI(jq("#tags").val());
			lastXhr = jq.getJSON( "/ajax/search?mod=wow&query="+query, request, function( data, status, xhr ) {
				cache[ term ] = data;
				if ( xhr === lastXhr ) {
					response( data );
				}
			});
		}
	});
	
	//SEARCH
	jq("#wow_search").click(function(){
		var query = encodeURI(jq("#tags").val());
		if (query){
			window.open('/wow/search?q='+query, "_self");	
		}
	});
	

	jq("ul.sf-menu").superfish().find('ul').bgIframe({opacity:false}); 


});


function AddFavorite(sURL, sTitle) { 
    try { 
        window.external.addFavorite(sURL, sTitle); 
    } catch (e) { 
        try { 
            window.sidebar.addPanel(sTitle, sURL, ""); 
        } catch (e) { 
			jq( "#dialog-Member" ).html("&nbsp;&nbsp;请使用 CTRL+D 收藏本站！");
			jq( "#dialog-Member" ).dialog( "open" );
            //alert("请使用 CTRL+D 收藏本站！"); 
        } 
    } 
} 
